/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package tallerfinal.view.distributions;

import tallerfinal.util.enums.DistributionsName;
import tallerfinal.view.distributions.factory.GeneratorViewFactory;

/**
 *
 * @author ricardo
 */
public class NormalView extends GeneratorView {

    static {
        GeneratorViewFactory.getInstance().registerProduct(DistributionsName.NORMAL, NormalView.class);
    }
    private Number media;
    private Number var;

    /**
     * Creates new form NormalView
     */
    public NormalView() {
        initComponents();
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel1 = new javax.swing.JLabel();
        mediaField = new javax.swing.JFormattedTextField();
        jLabel2 = new javax.swing.JLabel();
        varField = new javax.swing.JFormattedTextField();

        setBackground(new java.awt.Color(255, 255, 255));
        setBorder(javax.swing.BorderFactory.createTitledBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 0, 0), 1, true), "Editor Distribucion Normal"));
        setPreferredSize(new java.awt.Dimension(250, 100));
        setLayout(new java.awt.GridLayout(2, 2));

        jLabel1.setText("Media: ");
        add(jLabel1);

        mediaField.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.NumberFormatter()));
        mediaField.addAncestorListener( new RequestFocusListener() );
        add(mediaField);

        jLabel2.setText("Varianza: ");
        add(jLabel2);

        varField.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.NumberFormatter()));
        add(varField);
    }// </editor-fold>//GEN-END:initComponents
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JFormattedTextField mediaField;
    private javax.swing.JFormattedTextField varField;
    // End of variables declaration//GEN-END:variables

    @Override
    public Object[] getData() {
        media = (Number) mediaField.getValue();
        var = (Number) varField.getValue();
        return new Object[]{media.doubleValue(), var.doubleValue()};

    }

    @Override
    public String tosString() {
        return "Distribucion Normal Media = " + media.doubleValue() + " Varianza = " + var.doubleValue();
    }
}
